<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="author" content="kfzjw008">
    
    <meta name="description" content="IT开发交流社区，新媒体制作交流平台，大学生竞赛相关信息，计算机相关学科必备">
    
    
    
    
    
    
    <title>蓝桥杯比赛前夜-知识总结 | 几何军工作室</title>
    <!-- inject:style -->
    <link href="/css/style.css" rel="stylesheet" type="text/css">
    <!-- endinject -->
    <style>
        .cube-loading {
            top: 0;
            position: fixed;
            width: 100%;
            height: 100%;
            background: url('/images/lg/loading.gif') no-repeat center center;
            background-color: rgba(0,0,0,.7);
        }

        .cube-loading.out {
            display: none;
        }

        .cube-loading:before {
            display: block;
            content: '加载中';
            position: relative;
            width: 100%;
            top: 50%;
            right: -50%;
            color: #fff;
        }

        @media(max-width: 768px) {
            .cube-loading:before {
                font-size: 1.2em;
                transform: translate(-24px,20px);
                -webkit-transform: translate(-24px,20px);
                -o-transform: translate(-24px,20px);
                -ms-transform: translate(-24px,20px);
            }
        }

        @media(min-width: 768px) {
            .cube-loading:before {

            }
        }
    </style>
    
</head>
<body>
<div class="cube-body">
    <nav id="cube-top-memu" class="cube-menu">
    <ul class="cube-menu-collapse">
        
        <li>
            <i class="cube-icon cube-icon-home" aria-hidden="true"></i>
            <a href="/">首页</a>
        </li>
        
        <li>
            <i class="cube-icon cube-icon-categories" aria-hidden="true"></i>
            <a href="/categories">分类</a>
        </li>
        
        <li>
            <i class="cube-icon cube-icon-tags" aria-hidden="true"></i>
            <a href="/project">工程项目</a>
        </li>
        
        <li>
            <i class="cube-icon cube-icon-archive" aria-hidden="true"></i>
            <a href="/competition">学科竞赛</a>
        </li>
        
        <li>
            <i class="cube-icon cube-icon-archive" aria-hidden="true"></i>
            <a href="/zone">原创空间</a>
        </li>
        
        <li>
            <i class="cube-icon cube-icon-about" aria-hidden="true"></i>
            <a href="/about-me">关于我</a>
        </li>
        
    </ul>
</nav>
<nav class="cube-side-menu" id="cube-side-menu">
    <ul class="cube-menu-list">
        
        <li>
            <a class="lrc-control">开启歌词</a>
        </li>
        
        <li>
            <a class="scroll-to-top">回到顶部</a>
        </li>
    </ul>
</nav>
    <header class="cube-header" id="cube-header">
    <img src=" http://benyouhuifile.it168.com/forum/201204/20/154242hp8pmqm6t3izc8it.jpg " alt="头部背景图片">
    
    <div class="cube-type">
        <span class="cube-typed-title">几何军工作室</span>
        <span class="cube-typed-cursor">|</span>
    </div>
    
</header>

    <style>
        nav.cube-menu:before {
            content: '';
            visibility: hidden;
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            height: 44px;
        
            filter: blur(5px);
            -webkit-filter: blur(5px);
        
            z-index: -1;
            background-image: url('http://benyouhuifile.it168.com/forum/201204/20/154242hp8pmqm6t3izc8it.jpg');
            background-repeat: no-repeat;
            background-position: center -356px;
            background-size: cover;
            background-color: transparent;
        }

        header.cube-background.cube-header-background {
            visibility: hidden;
            background-image: url('http://benyouhuifile.it168.com/forum/201204/20/154242hp8pmqm6t3izc8it.jpg');
            background-position: center -400px;
        }
    </style>
    <header class="cube-background cube-header-background">
        
        <div class="cube-type">
            <span class="cube-typed-title">几何军工作室</span>
            <span class="cube-typed-cursor">|</span>
        </div>
        
    </header>
    <div class="load-header-background"></div>
    <script>
        (function (window) {

            window.headerModule = {}
            window.headerModule.image = {
                width: '2000',
                height: '850'
            }

        })(window)
    </script>
    
    <div class="cube-content">
        <div class="cube-left">
            <div class="cube-article">
    <h1 class="title">蓝桥杯比赛前夜-知识总结</h1>
    
    <div class="cube-article-header">
        <div class="cube-article-date">
            <i class="cube-icon cube-icon-date" aria-hidden="true"></i>
            <!-- moment.js对象 -->
            2019-03-23
            <span id="busuanzi_container_page_pv">
  本文总阅读量<span id="busuanzi_value_page_pv"></span>次
                   
</span>
        </div>
        <div class="cube-article-tags">
    <i class="cube-icon cube-icon-tag" aria-hidden="true"></i>
    
    <a href="/tags/算法/">#算法</a>
    
    <a href="/tags/蓝桥杯/">#蓝桥杯</a>
    
</div>
    </div>
    
    
    <div class="cube-article-content cube-markdown">
        
        <p>基于蓝桥杯近年来相关知识点和部分算法知识点制作此总结，仅用于蓝桥杯比赛前夜突击。</p>
<h1 id="二进制枚举子集"><a href="#二进制枚举子集" class="headerlink" title="二进制枚举子集"></a>二进制枚举子集</h1><p>从 n 个数中选任意个数，仅用加法凑出 x，求解决方案有多少种。</p>
<a id="more"></a>
<p>例：6 个数中凑出和为 6<br>123456</p>
<p>二进制枚举子集可以解决该问题：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">&lt;stdio.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">&lt;string.h&gt;</span></span></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line"><span class="keyword">int</span> n,x;</span><br><span class="line"><span class="keyword">int</span> i,j,k;</span><br><span class="line"><span class="keyword">int</span> a[<span class="number">30</span>];</span><br><span class="line"><span class="keyword">int</span> aa[<span class="number">30</span>];</span><br><span class="line"><span class="keyword">int</span> z=<span class="number">0</span>;</span><br><span class="line"><span class="keyword">int</span> sum;</span><br><span class="line"><span class="built_in">scanf</span>(<span class="string">"%d%d"</span>,&amp;n,&amp;x);</span><br><span class="line"><span class="keyword">for</span>(i=<span class="number">0</span>;i&lt;n;i++)</span><br><span class="line">&#123;</span><br><span class="line">	<span class="built_in">scanf</span>(<span class="string">"%d"</span>,&amp;a[i]);</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">for</span>(i=<span class="number">0</span>;i&lt;(<span class="number">1</span>&lt;&lt;n);i++)<span class="comment">//循环所有情况（每种数字对应0和1的2^n次情况）</span></span><br><span class="line">&#123;</span><br><span class="line">	sum=<span class="number">0</span>;<span class="comment">//每种情况的初始值</span></span><br><span class="line">	<span class="keyword">for</span>(j=<span class="number">0</span>;j&lt;n;j++)</span><br><span class="line">	&#123;</span><br><span class="line">		<span class="keyword">if</span>(i&amp;(<span class="number">1</span>&lt;&lt;j))<span class="comment">//循环n个数依次判断是否为1，如为1则在该种情况中计算在内</span></span><br><span class="line">		&#123;</span><br><span class="line">			sum=sum+a[j];</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">if</span>(sum==x)<span class="comment">//判断当前方案是否可行</span></span><br><span class="line">	&#123;</span><br><span class="line">		z=z+<span class="number">1</span>;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="built_in">printf</span>(<span class="string">"%d"</span>,z);</span><br><span class="line"><span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="日期计算"><a href="#日期计算" class="headerlink" title="日期计算"></a>日期计算</h1><ul>
<li>判断是否为闰年：</li>
</ul>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">is_leap_year</span><span class="params">(<span class="keyword">int</span> year)</span> </span>&#123;<span class="comment">//判断是否为闰年</span></span><br><span class="line">    <span class="keyword">if</span> (year % <span class="number">400</span> == <span class="number">0</span> || (year % <span class="number">100</span> != <span class="number">0</span> &amp;&amp; year % <span class="number">4</span> == <span class="number">0</span>)) &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="number">1</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ul>
<li>计算某年某月某日是星期几：</li>
</ul>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;string&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">whatday</span><span class="params">(<span class="keyword">int</span> y, <span class="keyword">int</span> m, <span class="keyword">int</span> d)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">if</span>(m==<span class="number">1</span>)&#123;m=<span class="number">13</span>;y=y<span class="number">-1</span>;&#125;</span><br><span class="line">    <span class="keyword">if</span>(m==<span class="number">2</span>)&#123;m=<span class="number">14</span>;y=y<span class="number">-1</span>;&#125;</span><br><span class="line">    <span class="keyword">return</span> (d+m*<span class="number">2</span>+<span class="number">3</span>*(m+<span class="number">1</span>)/<span class="number">5</span>+y+y/<span class="number">4</span>-y/<span class="number">100</span>+y/<span class="number">400</span>)%<span class="number">7</span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="built_in">string</span> weekday[<span class="number">7</span>] = &#123;<span class="string">"Monday"</span>, <span class="string">"Tuesday"</span>, <span class="string">"Wednesday"</span>, <span class="string">"Thursday"</span>, <span class="string">"Friday"</span>, <span class="string">"Saturday"</span>, <span class="string">"Sunday"</span>&#125;;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    <span class="keyword">int</span> y, m, d;</span><br><span class="line">    <span class="built_in">cin</span> &gt;&gt; y &gt;&gt; m &gt;&gt; d;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; weekday[whatday(y, m, d)] &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="C-标准模板库-STL"><a href="#C-标准模板库-STL" class="headerlink" title="C++ 标准模板库(STL)"></a>C++ 标准模板库(STL)</h1><p>C++ STL (Standard Template Library 标准模板库) 是通用类模板和算法的集合，它提供给程序员一些标准的数据结构的实现如 queues(队列), lists(链表), 和 stacks(栈)等.</p>
<p><strong>C++ STL 提供给程序员以下三类数据结构的实现:</strong></p>
<ul>
<li>顺序结构<br>C++ Vectors<br>C++ Lists<br>C++ Double-Ended Queues</li>
<li>容器适配器<br>C++ Stacks<br>C++ Queues<br>C++ Priority Queues</li>
<li>联合容器<br>C++ Bitsets<br>C++ Maps<br>C++ Multimaps<br>C++ Sets<br>C++ Multisets<br>程序员使用复杂数据结构的最困难的部分已经由 STL 完成. 如果程序员想使用包含 int 数据的 stack, 他只要写出如下的代码:</li>
</ul>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">stack</span>&lt;<span class="keyword">int</span>&gt; myStack;</span><br></pre></td></tr></table></figure>
<p>接下来, 他只要简单的调用 push() 和 pop() 函数来操作栈. 借助 C++ 模板的威力, 他可以指定任何的数据类型，不仅仅是 int 类型. STL stack 实现了栈的功能，而不管容纳的是什么数据类型。<br>以上类型常用为 Vector，queue，stack，map，set，均在文档中提供使用方式。</p>
<p>集合、映射表、等迭代器输出：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;set&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;string&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    <span class="built_in">set</span>&lt;<span class="built_in">string</span>&gt; country;  <span class="comment">// &#123;&#125;</span></span><br><span class="line">    country.insert(<span class="string">"China"</span>); <span class="comment">// &#123;"China"&#125;</span></span><br><span class="line">    country.insert(<span class="string">"America"</span>); <span class="comment">// &#123;"China", "America"&#125;</span></span><br><span class="line">    country.insert(<span class="string">"France"</span>); <span class="comment">// &#123;"China", "America", "France"&#125;</span></span><br><span class="line">    <span class="keyword">for</span> (<span class="built_in">set</span>&lt;<span class="built_in">string</span>&gt;::iterator it = country.begin(); it != country.end(); ++it) &#123;</span><br><span class="line">        <span class="built_in">cout</span> &lt;&lt; (*it) &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ul>
<li>优先队列示意：(重点理解优先级重载方法即可)</li>
</ul>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;queue&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;map&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="built_in">map</span>&lt;<span class="keyword">int</span>, <span class="keyword">int</span>&gt; timed;</span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">tasker</span> &#123;</span></span><br><span class="line">  <span class="keyword">int</span> tanum, tatim;</span><br><span class="line">  <span class="keyword">bool</span> <span class="keyword">operator</span>&lt;(<span class="keyword">const</span> tasker &amp;a) <span class="keyword">const</span> &#123;</span><br><span class="line">    <span class="keyword">if</span> (tatim &gt; a.tatim)</span><br><span class="line">      <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">    <span class="keyword">if</span> ((tatim == a.tatim) &amp;&amp; (tanum &gt; a.tanum))</span><br><span class="line">      <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">    <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">     &#125;</span><br><span class="line">&#125;;</span><br><span class="line">priority_queue&lt;tasker&gt;  tas;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</span><br><span class="line">  <span class="keyword">int</span> n, k;</span><br><span class="line">  <span class="built_in">cin</span> &gt;&gt; n &gt;&gt; k;</span><br><span class="line">  <span class="keyword">while</span> (n--) &#123;</span><br><span class="line">    <span class="built_in">string</span> buf;</span><br><span class="line">    <span class="keyword">int</span> num, tim;</span><br><span class="line">    <span class="built_in">cin</span> &gt;&gt; buf &gt;&gt; num &gt;&gt; tim;</span><br><span class="line">    tasker a;</span><br><span class="line">    timed[num] = tim;</span><br><span class="line">    a.tanum = num;</span><br><span class="line">    a.tatim = tim;</span><br><span class="line">    tas.push(a);</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">for</span> (<span class="keyword">int</span> m = <span class="number">0</span>; m &lt; k; m++) &#123;</span><br><span class="line">    tasker tmp;</span><br><span class="line">    tmp = tas.top();</span><br><span class="line">    tas.pop();</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; tmp.tanum &lt;&lt; <span class="string">"\n"</span>;</span><br><span class="line">    tmp.tatim +=timed[tmp.tanum];</span><br><span class="line">    tas.push(tmp);</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="并查集"><a href="#并查集" class="headerlink" title="并查集"></a>并查集</h1><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//初始化</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">init</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= n; ++i) &#123;</span><br><span class="line">        father[i] = i;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//查找节点所在根节点</span></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">get</span><span class="params">(<span class="keyword">int</span> x)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">if</span> (father[x] == x) &#123; <span class="comment">// x 结点就是根结点</span></span><br><span class="line">        <span class="keyword">return</span> x;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> get(father[x]); <span class="comment">// 返回父结点的根结点</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//两个元素所在集合合并</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">merge</span><span class="params">(<span class="keyword">int</span> x, <span class="keyword">int</span> y)</span> </span>&#123;</span><br><span class="line">    x = get(x);</span><br><span class="line">    y = get(y);</span><br><span class="line">    <span class="keyword">if</span> (x != y) &#123; <span class="comment">// 不在同一个集合</span></span><br><span class="line">        father[y] = x;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//以上为常用操作</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//路径压缩</span></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">get</span><span class="params">(<span class="keyword">int</span> x)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">if</span> (father[x] == x) &#123; <span class="comment">// x 结点就是根结点</span></span><br><span class="line">        <span class="keyword">return</span> x;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> father[x] = get(father[x]); <span class="comment">// 返回父结点的根结点，并另当前结点父结点直接为根结点</span></span><br><span class="line">&#125;<span class="comment">//关心父节点，不关心真正的结构</span></span><br></pre></td></tr></table></figure>
<p>使用范例：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//有若干对朋友关系，询问其中两人是不是朋友</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">&lt;stdio.h&gt;</span></span></span><br><span class="line"><span class="keyword">int</span> father[<span class="number">5005</span>],ans[<span class="number">5005</span>];</span><br><span class="line"><span class="keyword">int</span> n,m,p;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">init</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= n; ++i) &#123;</span><br><span class="line">        father[i] = i;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">get</span><span class="params">(<span class="keyword">int</span> x)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">if</span> (father[x] == x) &#123; <span class="comment">// x 结点就是根结点</span></span><br><span class="line">        <span class="keyword">return</span> x;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> father[x] = get(father[x]); <span class="comment">// 返回父结点的根结点，并另当前结点父结点直接为根结点</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">merge</span><span class="params">(<span class="keyword">int</span> x, <span class="keyword">int</span> y)</span> </span>&#123;</span><br><span class="line">    x = get(x);</span><br><span class="line">    y = get(y);</span><br><span class="line">    <span class="keyword">if</span> (x != y) &#123; <span class="comment">// 不在同一个集合</span></span><br><span class="line">        father[y] = x;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">	<span class="keyword">int</span> x,y;</span><br><span class="line">	<span class="built_in">scanf</span>(<span class="string">"%d%d%d"</span>,&amp;n,&amp;m,&amp;p);</span><br><span class="line">	init();</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">1</span>;i &lt;= m;i ++)&#123;</span><br><span class="line">		<span class="built_in">scanf</span>(<span class="string">"%d%d"</span>,&amp;x,&amp;y);</span><br><span class="line">		merge(x,y);</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">1</span>;i &lt;= p;i ++)&#123;</span><br><span class="line">		<span class="built_in">scanf</span>(<span class="string">"%d%d"</span>,&amp;x,&amp;y);</span><br><span class="line">		<span class="keyword">if</span>(get(x) == get(y))&#123;</span><br><span class="line">			ans[i] = <span class="number">1</span>;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">1</span>;i &lt;= p;i ++)&#123;</span><br><span class="line">		<span class="keyword">if</span>(ans[i] == <span class="number">1</span>)&#123;</span><br><span class="line">			<span class="built_in">printf</span>(<span class="string">"Yes\n"</span>);</span><br><span class="line">		&#125;<span class="keyword">else</span>&#123;</span><br><span class="line">			<span class="built_in">printf</span>(<span class="string">"No\n"</span>);</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="带权并查集"><a href="#带权并查集" class="headerlink" title="带权并查集"></a>带权并查集</h1><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//初始化，size为元素个数，dist为元素距离</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">init</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= n; i++)  &#123;</span><br><span class="line">        father[i] = i, dist[i] = <span class="number">0</span>, size[i] = <span class="number">1</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//查找</span></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">get</span><span class="params">(<span class="keyword">int</span> x)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">if</span>(father[x] == x) &#123;</span><br><span class="line">        <span class="keyword">return</span> x;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">int</span> y = father[x];</span><br><span class="line">    father[x] = get(y);</span><br><span class="line">    dist[x] += dist[y];  <span class="comment">// x 到根结点的距离等于 x 到之前父亲结点距离加上之前父亲结点到根结点的距离</span></span><br><span class="line">    <span class="keyword">return</span> father[x];</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//合并</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">merge</span><span class="params">(<span class="keyword">int</span> a, <span class="keyword">int</span> b)</span> </span>&#123;</span><br><span class="line">    a = get(a);</span><br><span class="line">    b = get(b);</span><br><span class="line">    <span class="keyword">if</span>(a != b) &#123;  <span class="comment">// 判断两个元素是否属于同一集合</span></span><br><span class="line">        father[a] = b;</span><br><span class="line">        dist[a] = size[b];</span><br><span class="line">        size[b] += size[a];</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="深度优先搜索示例"><a href="#深度优先搜索示例" class="headerlink" title="深度优先搜索示例"></a>深度优先搜索示例</h1><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//走迷宫</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="keyword">int</span> n,m;</span><br><span class="line"><span class="keyword">char</span> a[<span class="number">11</span>][<span class="number">11</span>];</span><br><span class="line"></span><br><span class="line"><span class="keyword">int</span> vis[<span class="number">11</span>][<span class="number">11</span>];</span><br><span class="line"><span class="keyword">int</span> sum=<span class="number">0</span>;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">dfs</span><span class="params">(<span class="keyword">int</span> x,<span class="keyword">int</span> y)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">int</span> i,j;</span><br><span class="line"><span class="keyword">if</span>(a[x][y]==<span class="string">'T'</span>)&#123;<span class="comment">//终点返回</span></span><br><span class="line">    sum=sum+<span class="number">1</span>;<span class="keyword">return</span>;<span class="comment">//碰到终点就有一种方案了，故sum+1</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">        vis[x][y]=<span class="number">1</span>;<span class="comment">//访问记录</span></span><br><span class="line">        <span class="keyword">for</span>(i=<span class="number">-1</span>;i&lt;=<span class="number">1</span>;++i)<span class="comment">//四个方向的遍历</span></span><br><span class="line">            <span class="keyword">for</span>(j=<span class="number">-1</span>;j&lt;=<span class="number">1</span>;++j)</span><br><span class="line">            &#123;</span><br><span class="line">                <span class="keyword">if</span>((i-j!=<span class="number">0</span>)&amp;&amp;(i+j!=<span class="number">0</span>))</span><br><span class="line">                &#123;</span><br><span class="line">                    <span class="keyword">if</span>((x+i&gt;=<span class="number">0</span>&amp;&amp;x+i&lt;n)&amp;&amp;(y+j&gt;=<span class="number">0</span>&amp;&amp;y+j&lt;m)&amp;&amp;a[x+i][y+j]!=<span class="string">'#'</span>&amp;&amp;vis[x+i][y+j]==<span class="number">0</span>)&#123;</span><br><span class="line">                        <span class="comment">//符合条件就dfs</span></span><br><span class="line">                        dfs(x+i,y+j);</span><br><span class="line">                    &#125;</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">         vis[x][y]=<span class="number">0</span>;<span class="comment">//访问结束归位</span></span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//重点是上面这个dfs函数</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="built_in">cin</span>&gt;&gt;n&gt;&gt;m;</span><br><span class="line">	<span class="keyword">int</span> x,y;</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">0</span>;i&lt;n;i++)</span><br><span class="line">	&#123;</span><br><span class="line">		<span class="keyword">for</span>(<span class="keyword">int</span> j=<span class="number">0</span>;j&lt;m;j++)</span><br><span class="line">		&#123;</span><br><span class="line">			<span class="built_in">cin</span>&gt;&gt;a[i][j];</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">0</span>;i&lt;n;i++)</span><br><span class="line">	&#123;</span><br><span class="line">		<span class="keyword">for</span>(<span class="keyword">int</span> j=<span class="number">0</span>;j&lt;m;j++)</span><br><span class="line">		&#123;</span><br><span class="line">			<span class="keyword">if</span>(a[i][j]==<span class="string">'S'</span>)</span><br><span class="line">			&#123;</span><br><span class="line">				dfs(i,j);</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="built_in">cout</span>&lt;&lt;sum&lt;&lt;<span class="built_in">endl</span>;</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>剪枝即在各种不同情况或者不满足的情况下进行的直接 return 操作。</p>
<h1 id="广度优先搜索示例"><a href="#广度优先搜索示例" class="headerlink" title="广度优先搜索示例"></a>广度优先搜索示例</h1><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;queue&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstring&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> MAXN = <span class="number">110</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">int</span> vis[MAXN][MAXN];</span><br><span class="line"><span class="keyword">int</span> ret[MAXN][MAXN];</span><br><span class="line"><span class="keyword">char</span> a[MAXN][MAXN];</span><br><span class="line"><span class="keyword">int</span> xx[<span class="number">4</span>] = &#123;<span class="number">0</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">-1</span>&#125;;</span><br><span class="line"><span class="keyword">int</span> yy[<span class="number">4</span>] = &#123;<span class="number">1</span>, <span class="number">-1</span>, <span class="number">0</span>, <span class="number">0</span>&#125;;</span><br><span class="line"><span class="keyword">int</span> n, m;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">bfs</span><span class="params">(<span class="keyword">int</span> x, <span class="keyword">int</span> y)</span> </span>&#123;</span><br><span class="line">	<span class="built_in">queue</span>&lt; pair&lt;<span class="keyword">int</span>, <span class="keyword">int</span>&gt; &gt; q;</span><br><span class="line">	q.push(make_pair(x,y));</span><br><span class="line">	vis[x][y] = <span class="number">1</span>;</span><br><span class="line">	ret[x][y] = <span class="number">0</span>;</span><br><span class="line">	<span class="keyword">while</span>(!q.empty()) &#123;</span><br><span class="line">		<span class="keyword">int</span> tx = q.front().first;</span><br><span class="line">		<span class="keyword">int</span> ty = q.front().second;</span><br><span class="line">		q.pop();</span><br><span class="line">		<span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>;i &lt; <span class="number">4</span>; ++i) &#123;</span><br><span class="line">			<span class="keyword">int</span> txx = tx + xx[i];</span><br><span class="line">			<span class="keyword">int</span> tyy = ty + yy[i];</span><br><span class="line">			<span class="keyword">if</span> (txx &gt;= <span class="number">0</span> &amp;&amp; txx &lt; n &amp;&amp; tyy &gt;= <span class="number">0</span> &amp;&amp; tyy &lt; m &amp;&amp; !vis[txx][tyy] &amp;&amp; a[txx][tyy] != <span class="string">'#'</span>) &#123;</span><br><span class="line">				ret[txx][tyy] = ret[tx][ty] + <span class="number">1</span>;</span><br><span class="line">				vis[txx][tyy] = <span class="number">1</span>;</span><br><span class="line">				<span class="keyword">if</span> (a[txx][tyy] == <span class="string">'T'</span>) &#123;</span><br><span class="line">					<span class="keyword">return</span> ret[txx][tyy];</span><br><span class="line">				&#125;</span><br><span class="line">				q.push(make_pair(txx, tyy));</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">return</span> <span class="number">-1</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</span><br><span class="line">	<span class="built_in">memset</span>(vis, <span class="number">0</span>, <span class="keyword">sizeof</span>(vis));</span><br><span class="line">	<span class="built_in">memset</span>(ret, <span class="number">0</span>, <span class="keyword">sizeof</span>(ret));</span><br><span class="line">	<span class="keyword">int</span> bx, by;</span><br><span class="line">	<span class="keyword">int</span> ex, ey;</span><br><span class="line">	<span class="built_in">scanf</span>(<span class="string">"%d %d"</span>, &amp;n, &amp;m);</span><br><span class="line">	<span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>;i &lt; n; ++i) &#123;</span><br><span class="line">		<span class="built_in">scanf</span>(<span class="string">"%s"</span>, a[i]);</span><br><span class="line">		<span class="keyword">for</span> (<span class="keyword">int</span> j = <span class="number">0</span>;j &lt; m; ++j) &#123;</span><br><span class="line">			<span class="keyword">if</span> (a[i][j] == <span class="string">'S'</span>) &#123;</span><br><span class="line">				bx = i;</span><br><span class="line">				by = j;</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"%d\n"</span>, bfs(bx, by));</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>需要重点看，稍微比深度优先遍历复杂。</p>
<h1 id="必要的细节"><a href="#必要的细节" class="headerlink" title="必要的细节"></a>必要的细节</h1><ul>
<li>输入字符串如果读入不对则可以尝试：getchar()或者 cin。<br>-</li>
</ul>

    </div>
</div>

<div class="cube-article-nav">
    <ul>
        
        <li class="prev">
            <a href="/2019/03/25/2036/">
                <i class="cube-icon cube-prev" aria-hidden="true"></i>
                JAVA学习笔记
            </a>
        </li>
        
        
        <li class="next">
            <a href="/2019/03/21/2034/">
                建立友好合作博客的方式
                <i class="cube-icon cube-next" aria-hidden="true"></i>
            </a>
        </li>
        
    </ul>
</div>


<!-- TODO 根据theme.comment的内容进行入口选择 -->


<!-- Table of Contents -->

        </div>
        <div class="cube-right">
            

<div class="cube-search cube-sidebar" id="cube-search">
    <div class="search-container">
        <input type="text" placeholder="搜索" class="cube-search-input" id="cube-search-input">
        <i class="cube-icon cube-icon-search cube-search-submit" aria-hidden="true"></i>
    </div>
    <!-- TODO 通过给window赋一个全局变量，通过脚本赋值 -->
</div>
<script>
    (function (window) {
        'use strict';
        window.searchModule = {}
        window.searchModule.JSONUrl = '/content.json'
        window.searchModule.rootUrl = '/'
    })(window)
</script>
<div class="cube-search-form">
    <div class="cube-search-control">
        <input type="text" placeholder="搜索" class="search-input">
        <a class="close-button">
            <i class="cube-icon cube-close" aria-hidden="true"></i>
        </a>
    </div>
    <div class="cube-search-result"></div>
</div>


<div class="cube-author cube-sidebar" id="cube-author">
    
    
    <span>kfzjw008</span>
    
    
    <a title="IT开发交流社区，新媒体制作交流平台，大学生竞赛相关信息，计算机相关学科必备">IT开发交流社区，新媒体制作交流平台，大学生竞赛相关信息，计算机相关学科必备</a>
    
    <div class="count">
        <a class="count articles"><span>25</span>文章</a>
        <a class="count tags"><span>22</span>标签</a>
        <a class="count categories"><span>7</span>分类</a>
    </div>
</div>



<div class="cube-music cube-sidebar" id="cube-music">
    <div class="cube-player aplayer" id="cube-player"></div>
</div>
<script>
    (function (window) {
        window.musicModule = {}
        window.musicModule.musicConfig = '{"narrow":false,"autoplay":true,"showlrc":3,"theme":"#b7daff","mutex":true,"mode":"circulation","preload":"auto","listmaxheight":"513px","music":[{"title":"光明","author":"汪峰","url":"http://47.95.213.193/mp3data/%e5%85%89%e6%98%8e-%e6%b1%aa%e5%b3%b0.mp3","pic":"http://47.95.213.193/mp3data/%e6%b1%aa%e5%b3%b02017%e7%bb%8f%e5%85%b8%e6%ad%8c%e6%9b%b2%e6%96%b0%e7%bc%96%e7%b2%be%e9%80%89%e9%9b%86I.jpg"},{"title":"不羁的生命","author":"汪峰","url":"http://47.95.213.193/mp3data/%e4%b8%8d%e7%be%81%e7%9a%84%e7%94%9f%e5%91%bd-%e6%b1%aa%e5%b3%b0.mp3","pic":"http://47.95.213.193/mp3data/%e6%b1%aa%e5%b3%b02017%e7%bb%8f%e5%85%b8%e6%ad%8c%e6%9b%b2%e6%96%b0%e7%bc%96%e7%b2%be%e9%80%89%e9%9b%86I.jpg"},{"title":"上千个黎明","author":"汪峰","url":"http://47.95.213.193/mp3data/%e6%b1%aa%e5%b3%b0-%e4%b8%8a%e5%8d%83%e4%b8%aa%e9%bb%8e%e6%98%8e.mp3","pic":"http://47.95.213.193/mp3data/%e6%b1%aa%e5%b3%b02017%e7%bb%8f%e5%85%b8%e6%ad%8c%e6%9b%b2%e6%96%b0%e7%bc%96%e7%b2%be%e9%80%89%e9%9b%86I.jpg"},{"title":"信仰在空中飘扬","author":"汪峰","url":"http://47.95.213.193/mp3data/%e4%bf%a1%e4%bb%b0%e5%9c%a8%e7%a9%ba%e4%b8%ad%e9%a3%98%e6%89%ac-%e6%b1%aa%e5%b3%b0.mp3","pic":"http://yoursite.com/images/music/null"},{"title":"像梦一样自由","author":"汪峰","url":"http://47.95.213.193/mp3data/%e5%83%8f%e6%a2%a6%e4%b8%80%e6%a0%b7%e8%87%aa%e7%94%b1-%e6%b1%aa%e5%b3%b0.mp3","pic":"http://yoursite.com/images/music/null"},{"title":"怒放的生命","author":"汪峰","url":"http://47.95.213.193/mp3data/%e6%80%92%e6%94%be%e7%9a%84%e7%94%9f%e5%91%bd-%e6%b1%aa%e5%b3%b0.mp3","pic":"http://yoursite.com/images/music/null"},{"title":"大桥上","author":"汪峰","url":"http://47.95.213.193/mp3data/%e6%b1%aa%e5%b3%b0%20-%20%e5%a4%a7%e6%a1%a5%e4%b8%8a.mp3","pic":"http://yoursite.com/images/music/null"},{"title":"流年啊，你奈我何","author":"汪峰","url":"http://47.95.213.193/mp3data/%e6%b5%81%e5%b9%b4%e5%95%8a%20%e4%bd%a0%e5%a5%88%e6%88%91%e4%bd%95-%e6%b1%aa%e5%b3%b0.mp3","pic":"http://yoursite.com/images/music/null"},{"title":"生来彷徨","author":"汪峰","url":"http://47.95.213.193/mp3data/%e7%94%9f%e6%9d%a5%e5%bd%b7%e5%be%a8-%e6%b1%aa%e5%b3%b0.mp3","pic":"http://yoursite.com/images/music/null"}]}'
        window.musicModule.lrcConfig = {
            open: '开启歌词',
            close: '关闭歌词'
        }
    })(window)
</script>



<div class="cube-recent-posts cube-sidebar" id="cube-recent-posts">
    <div class="title">
        <a>近期文章</a>
    </div>
    <ul class="list">
        
        
        <li>
            <!-- TODO 如果文章要显示图片，那么在front-matter上添加preview属性(url or path) -->
            
            <div class="normal">
                <p class="index first">
                    <span>1</span>
                </p>
                <p class="title">
                    <a href="/2019/03/27/2038/" title="JAVA学习笔记(2)-spring MVC">JAVA学习笔记(2)-spring MVC</a>
                </p>
            </div>
            
        </li>
        
        
        
        <li>
            <div class="normal">
                <p class="index">
                    <span>2</span>
                </p>
                <p class="title">
                    <a href="/2019/03/25/2036/" title="JAVA学习笔记">JAVA学习笔记</a>
                </p>
            </div>
        </li>
        
        
        
        <li>
            <div class="normal">
                <p class="index">
                    <span>3</span>
                </p>
                <p class="title">
                    <a href="/2019/03/25/2037/" title="设计模式学习笔记-01">设计模式学习笔记-01</a>
                </p>
            </div>
        </li>
        
        
        
        <li>
            <div class="normal">
                <p class="index">
                    <span>4</span>
                </p>
                <p class="title">
                    <a href="/2019/03/23/2035/" title="蓝桥杯比赛前夜-知识总结">蓝桥杯比赛前夜-知识总结</a>
                </p>
            </div>
        </li>
        
        
        
        <li>
            <div class="normal">
                <p class="index">
                    <span>5</span>
                </p>
                <p class="title">
                    <a href="/2019/03/21/2034/" title="建立友好合作博客的方式">建立友好合作博客的方式</a>
                </p>
            </div>
        </li>
        
        
    </ul>
</div>



<div class="cube-categories cube-sidebar" id="cube-categories">
    <div class="title">
        <a href="/categories">分类</a>
    </div>
    <div class="cube-boxs">
        
        
        <div class="cube-box ">
            <a href="/categories/WEB开发/">#WEB开发</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/categories/蓝桥杯/">#蓝桥杯</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/categories/XML/">#XML</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/categories/数据库/">#数据库</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/categories/博客公告/">#博客公告</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/categories/设计模式/">#设计模式</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/categories/JAVA/">#JAVA</a>
        </div>
        
    </div>
</div>



<div class="cube-tagcloud cube-sidebar" id="cube-tagcloud">
    <div class="title">
        <a href="/tags">标签云</a>
    </div>
    <div class="cube-boxs">
        
        
        <div class="cube-box-bg ">
            <a href="/tags/servlet/">#servlet</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/tags/期末复习/">#期末复习</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/tags/HTML/">#HTML</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/tags/CSS/">#CSS</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/tags/前端/">#前端</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/tags/算法/">#算法</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/tags/蓝桥杯/">#蓝桥杯</a>
        </div>
        
        
        <div class="cube-box-bg ">
            <a href="/tags/随笔/">#随笔</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/tags/jQuery/">#jQuery</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/tags/JavaScript/">#JavaScript</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/tags/WEB-Service/">#WEB Service</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/tags/XML/">#XML</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/tags/题解/">#题解</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/tags/数据库/">#数据库</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/tags/MYSQL/">#MYSQL</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/tags/BLOG/">#BLOG</a>
        </div>
        
        
        <div class="cube-box-bg ">
            <a href="/tags/HEXO/">#HEXO</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/tags/设计模式/">#设计模式</a>
        </div>
        
        
        <div class="cube-box-bg ">
            <a href="/tags/JAVA/">#JAVA</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/tags/UML/">#UML</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/tags/软件体系结构/">#软件体系结构</a>
        </div>
        
        
        <div class="cube-box ">
            <a href="/tags/Spring-MVC/">#Spring MVC</a>
        </div>
        
    </div>
</div>



<div class="cube-links cube-sidebar" id="cube-links">
    <div class="title">
        <a>个人链接</a>
    </div>
    <ul class="list">
        
        <li>
            
            
            <img src="http://cube-1252774894.cosgz.myqcloud.com/links/GitHub.png">
            
            <a href="https://github.com/kfzjw008" target="_blank">我的GitHub</a>
        </li>
        
        <li>
            
            
            <img src="https://www.csdn.net/company/img/csdn-logo.svg">
            
            <a href="https://blog.csdn.net/kfzjw008" target="_blank">我的CSDN</a>
        </li>
        
        <li>
            
            
            <img src="http://cube-1252774894.cosgz.myqcloud.com/links/SF.png">
            
            <a href="https://47.95.213.193" target="_blank">我的个人主页</a>
        </li>
        
        <li>
            
            
            <img src="https://gss2.bdstatic.com/-fo3dSag_xI4khGkpoWK1HF6hhy/baike/w%3D268%3Bg%3D0/sign=fc01334b798b4710ce2ffacafbf5a4c0/1b4c510fd9f9d72a26f9db77df2a2834349bbb3f.jpg">
            
            <a href="https://www.zhihu.com/people/zhang-jun-wei-81-7/activities" target="_blank">我的知乎主页</a>
        </li>
        
    </ul>
</div>



<div class="cube-friend-links cube-sidebar" id="cube-friend-links">
    <div class="title">
        <a>友情链接</a>
    </div>
    <ul class="list">
        
        <li>
            <!-- TODO change avatar.png to friend.png-->
            <img src="http://cube-1252774894.cosgz.myqcloud.com/friend_links/micblo.png">
            <a href="https://github.com/MajorBill-Liu" target="_blank">MajorBill-Liu 的github</a>
        </li>
        
        <li>
            <!-- TODO change avatar.png to friend.png-->
            <img src="/images/friend_links.jpg ">
            <a href="https://kfzjw008.github.io/" target="_blank">此位置招租</a>
        </li>
        
        <li>
            <!-- TODO change avatar.png to friend.png-->
            <img src="/images/friend_links.jpg ">
            <a href="https://kfzjw008.github.io/" target="_blank">此位置招租</a>
        </li>
        
    </ul>
</div>


        </div>
    </div>
</div>
<footer class="cube-footer">
    
© 2017 kfzjw008

<br>
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
Powered by <a href="https://hexo.io/" target="_blank">Hexo</a>.&nbsp;Theme by <a href="https://github.com/ZEROKISEKI" target="_blank">AONOSORA</a>
<span id="busuanzi_container_site_pv">
    本站总访问量<span id="busuanzi_value_site_pv"></span>次
</span>


</footer>
<!-- inject:script -->
<script src="/js/script.js"></script>
<!-- endinject -->
<div class="cube-loading out"></div>
</body>
</html>